$result = Exams::whereNotIn('id', function($q){ $q->select('examId')->from('testresults'); })->get();